<template>
  <div class="bigbox">
    <div class="login">
      <div id="login">
        <h1>Register</h1>

        <input
          type="text"
          required="required"
          placeholder="用户名"
          name="u"
          v-model="v1"
        />
        <input
          type="password"
          required="required"
          placeholder="密码"
          name="p"
          v-model="v2"
        />
        <button class="but" type="submit" @click="login">注册</button>

        <router-link to="/login"
          ><span class="login">已有账号?马上登陆</span></router-link
        >
      </div>
    </div>
    <router-view />
  </div>
</template>
<script>
import Vue from "vue";
import { Toast } from "vant";

Vue.use(Toast);
export default {
  data() {
    return {
      v1: "",
      v2: "",
    };
  },
  methods: {
    login() {
      if (this.v1 && this.v2) {
        Toast.success("注册成功");
        let obj = {};
        obj.uname = this.v1;
        obj.pword = this.v2;
        localStorage.setItem("user用户注册", JSON.stringify(obj));
        this.$router.push({ path: "/login" });
      } else {
        Toast.fail("请检查用户名或密码");
        return;
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.bigbox {
  width: 100%;
  height: 100%;
  background-color: #61649f;
  // opacity: .8;
  position: fixed;
  top: 0;
  left: 0;
}
#login {
  position: absolute;
  top: 30%;
  left: 50%;
  margin: -130px 0 0 -150px;
  width: 300px;
  height: 300px;
  z-index: 10000;

  .login {
    font-size: 15px;
    color: #b0afb3;
    float: right;
    margin-top: 20px;
  }
}
#login h1 {
  color: #fff;
  text-shadow: 0 0 10px;
  letter-spacing: 1px;
  text-align: center;
}
h1 {
  font-size: 2em;
  margin: 0.67em 0;
}
input {
  width: 278px;
  height: 18px;
  margin-bottom: 10px;
  outline: none;
  padding: 10px;
  font-size: 13px;
  color: #fff;
  text-shadow: 1px 1px 1px;
  border-top: 1px solid #312e3d;
  border-left: 1px solid #312e3d;
  border-right: 1px solid #312e3d;
  border-bottom: 1px solid #56536a;
  border-radius: 4px;
  background-color: #2d2d3f;
}
.but {
  width: 300px;
  min-height: 20px;
  display: block;
  background-color: #4a77d4;
  border: 1px solid #3762bc;
  color: #fff;
  padding: 9px 14px;
  font-size: 15px;
  line-height: normal;
  border-radius: 5px;
  margin: 0;
}
</style>